package com.igeek.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.Array;
import java.util.Arrays;

@Component
@Aspect
public class MyAdvice {
    @Pointcut("execution(void com.igeek.dao.impl.BookDao.update())")
    public void bxj(){
    }
    @Pointcut("execution(int com.igeek.dao.impl.BookDao.select())")
    public void bxj2(){
    }
//    @Before("bxj()")
//    public void zzz(){
//        System.out.println(System.currentTimeMillis());
//    }
    @Around("bxj()")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around before advice");
        //表示对原始方法的调用
        joinPoint.proceed();
        System.out.println("around after advice");
    }
        @Around("bxj2()")
        public  Object around2(ProceedingJoinPoint joinPoint) throws Throwable {
//            System.out.println("around before advice");
            Object[] args=joinPoint.getArgs();
            System.out.println(Arrays.toString(args));
            //表示对原始方法的调用
//           Object obj= joinPoint.proceed();
//            System.out.println("around after advice");
            Object ret=joinPoint.proceed(args);
            return ret;
      }
    }

